<?php

namespace App\Enums\Message;

use App\Traits\EnumTrait;

class MessageSceneEnum
{
    use EnumTrait;

    const IM = ['scene' => 1, 'text' => 'IM'];
    const NOTIFICATION = ['scene' => 2, 'text' => '通知消息'];
    const INTERACTIVE_MESSAGE = ['scene' => 3, 'text' => '互动消息'];

    public static array $sceneToText = [];

    public static function getScene($data)
    {
        return $data['scene'];
    }

    public static function getText($data)
    {
        return $data['text'];
    }

    /**
     * 未读查询场景
     * @return array
     */
    public static function unreadQueryScene(): array
    {
        return [self::NOTIFICATION['scene'], self::INTERACTIVE_MESSAGE['scene']];
    }

    public static function getTextByScene(int $scene)
    {
        if (empty(self::$sceneToText)) {
            self::$sceneToText = array_column(self::getConstants(), 'text', 'scene');
        }
        return self::$sceneToText[$scene];
    }
}
